<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
<s:if test="%{id==null}">
Add
</s:if>
<s:else>
Edit
</s:else>
image
</title>
<style type="text/css">
	@IMPORT url("css/common.css");
	@IMPORT url("../css/view.css");
</style>
<style type="text/css">
    @import "http://o.aolcdn.com/dojo/0.9.0/dijit/themes/tundra/tundra.css";
    @import "http://o.aolcdn.com/dojo/0.9.0/dojo/dojo.css"
</style>
<script type="text/javascript" src="http://o.aolcdn.com/dojo/0.9.0/dojo/dojo.xd.js"
            djConfig="parseOnLoad: true"></script>
<script type="text/javascript">
   dojo.require("dojo.parser");
   dojo.require("dijit.form.DateTextBox");
   dojo.require("dijit.form.NumberTextBox");
   dojo.require("dijit.form.Button");
   dojo.require("dijit.form.Textarea");
   dojo.require("dijit.form.TextBox");
</script>
<script type="text/javascript">
	function submit(){
		dojo.byId('form1').submit();
	}
</script>
<script type="text/javascript" src="http://www.openlayers.org/api/OpenLayers.js" ></script>
<s:if test="%{id!=null}">
<script type="text/javascript">
	var _gmlUrl = '<s:url value="/process/positionGML.do" includeParams="none"/>?pathRow=<s:property value="path"/>,<s:property value="row"/>';
	var _x = <s:property value="x" />;
	var _y = <s:property value="y" />;
</script>
<script type="text/javascript" src="../scripts/view.js"></script>
<script type="text/javascript">
	function deleteImage(id){
		if(confirm('Delete this record?')){
			document.location = '<s:url value="/manage/imageDelete.do" includeParams="none"/>' + '?id=' + id;
		}
	}
</script>
</s:if>
</head>
<body 
<s:if test="%{id!=null}">
onload="initMap()" 
</s:if>
class="tundra" style="font-size: 13px;">
	<div class="bodywrap">
		<s:form id="form1" action="/manage/imageSave.do" method="post">
			<table style="text-align: left;">
				<tr>
					<td>Path</td>
					<td><input dojoType="dijit.form.NumberTextBox" require="true" type="text" name="path" size="10" value="<s:property value="path"/>"></input></td>
				</tr>
				<tr>
					<td>Row</td>
					<td><input dojoType="dijit.form.NumberTextBox" require="true" type="text" name="row" size="10" value="<s:property value="row"/>"></input></td>
				</tr>
				<tr>
					<td>Date</td>
					<td><input dojoType="dijit.form.DateTextBox" constraints="{datePattern:'M/d/yy'}" name="date" type="text" size="10" value="<s:property value="date"/>"></input></td>
				</tr>
				<tr>
					<td>File</td>
					<td><input dojoType="dijit.form.TextBox" style="width:400px;" require="true" type="text" name="dir" value="<s:property value="dir"/>"></input></td>
				</tr>
				<tr>
					<td>Sensor</td>
					<td><input dojoType="dijit.form.TextBox" style="width:300px;" require="false" type="text" name="sensor" value="<s:property value="sensor"/>"></input></td>
				</tr>
				<tr>
					<td>Source</td>
					<td><input dojoType="dijit.form.TextBox" style="width:400px;" require="false" type="text" name="source" value="<s:property value="source"/>"></input></td>
				</tr>
				<tr>
					<td>Cloud Percent</td>
					<td><input dojoType="dijit.form.NumberTextBox" require="false" type="text" name="cloud" size="10" value="<s:property value="cloud"/>"></input> %</td>
				</tr>
				<tr>
					<td>Quality</td>
					<td>
						<div dojoType="dijit.form.Textarea" style="width:500px;" name="quality" trim="true"><s:property value="quality"/>
						</div>
					</td>
				</tr>
				<tr>
					<td>Note</td>
					<td>
						<div dojoType="dijit.form.Textarea" style="width:500px;" name="note" trim="true"><s:property value="note"/>
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<s:if test="%{id==null}">
							<button dojoType="dijit.form.Button" onclick="submit();">
								Add
							</button>
						</s:if>
						<s:else>
							<button dojoType="dijit.form.Button" onclick="submit();">
								Edit
							</button>
							<button dojoType="dijit.form.Button" onclick="deleteImage('<s:property value="id" />');">
								Delete
							</button>
						</s:else>
						<button dojoType="dijit.form.Button" onclick="document.location='<s:url value="/manage/imageList.do" includeParams="none"/>';">Cancel</button>
					</td>
				</tr>
			</table>
			<input type="hidden" name="id" value="<s:property value="id" />" />
		</s:form>
		<div>
			<div id="map"></div>
		</div>
	</div>
</body>
</html>